import java.sql.*;
import static  java.lang.System.out;

public class ConnectionDemo {
    public static void main(String[] args)throws ClassNotFoundException, SQLException{
        Class.forName("com.mysql.jdbc.Driver");
        String jdbcUrl = "jdbc:mysql://localhost:3306/demo";
        String user = "root";
        String passwd = "openhome";
        try(Connection conn = DriverManager.getConnection(jdbcUrl,user,passwd)){
            out.printf("已%s数据库联机%n",conn.isClosed()?"关闭":"开启");
        }

    }
}